<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>多年年度计划</title>
    <link rel="stylesheet" href="../../../../res/layui/css/layui.css" media="all" type="text/css">
    <script src="../../../../res/js/jquery-3.1.1.min.js" type="text/javascript"
            charset="utf-8"></script>
    <script src="../../../../res/js/login_common.js" charset="utf-8"></script>
    <script src="../../../../res/layui/layui.js" charset="utf-8"></script>
    <script src="../../../../res/js/Tools.js"></script>
    <script>
        $.ajaxSetup({
            async : false
        });

    </script>
    <style>
        .layui-form-item .layui-input-inlinetwo {
            float: left;
            width: 130px;
            margin-right: 10px;
        }
        .layui-form-item .layui-input-inlinethree {
            float: left;
            width: 182px;
            margin-right: 10px;
        }
    </style>
</head>
<body>
<form class="layui-form" action="" id="formDId" lay-filter="example" method="post" enctype="multipart/form-data">
    <input type="hidden" id="rId" name="rId">

    <div class="layui-form-item">
        <label class="layui-form-label">请选择师傅</label>
        <div class="layui-input-block">
            <select id="sId" name="sId"  lay-filter="demo" lay-verify="required">
                <option value=""></option>
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button type="button" class="layui-btn site-demo-active" lay-submit lay-filter="formDemo">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
<script>

    var form=null;
    layui.use('form', function() {
        form = layui.form;
        //监听提交
        form.on('submit(formDemo)', function (data) {
            // 单击之后提交按钮不可选,防止重复提交
            var DISABLED = 'layui-btn-disabled';
            // 增加样式
            $('.site-demo-active').addClass(DISABLED);
            // 增加属性
            $('.site-demo-active').attr('disabled', 'disabled');
            var formData = new FormData(document.getElementById("formDId"));
            var url = "../../../../RepairTbController/update";
            $.ajax({
                url: url,
                type: "post",
                data: formData,
                processData: false,
                contentType: false,
                dataType: "json",
                success: function (obj) {
                    if (obj.num == 1) {
                        layer.msg(obj.msg, {
                            icon: 1,
                            time: 1000 //1秒关闭(如果不配置默认三秒)
                        }, function () {
                            //关闭当前层
                            //当你在iframe页面关闭自身时
                            parent.layui.table.reload("test");
                            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                            parent.layer.close(index); //再执行关闭
                            //刷新父页面

                            //parent.location.reload();
                        });
                        return false;
                    }
                },
                error: function (e) {
                    layer.msg("错误！！");
                }
            });
            return false;
        });
    })
        //修改操作
        var ide = getQueryString("id");

        if(ide) {
            $("#rId").val(ide);
            findById();//修改页面的赋值
        }
    //修改页面的赋值
    function findById(){

        var url="../../../../StaffTbController/selectAllTwo";
        var data=null;
        $.post(url,data,function(obj){
            $.each(obj,function(index,item){
                $("#sId").append("<option value='"+item.sId+"'>"+item.sName+"</option>");
            });
            form.render('select');
        },"json");
    }
/*    /!**
     * 复选框赋值
     *!/
    function checboxfu(){
        var id=getQueryString("id");
        var url="../../atsPlanYearMoreController/findByIdpid";
        var data={pid:id,remark:5};//多年计划
        $.post(url,data,function(obj){
            $.each(obj,function(index,item){
                $("#cc"+item.athleteId).attr("checked","checked");
                form.render("checkbox");
            })
        },"json");
    }*/
</script>
</body>
</html>